﻿using MyUAMS.BLL;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class UserWork_AssetCategory : System.Web.UI.Page
{
    CategoryServer categorySrv = new CategoryServer();
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void DetailsView1_ItemDeleting(object sender, DetailsViewDeleteEventArgs e)
    {
        var productCount = categorySrv.GetProductCountByCategoryId(int.Parse(DetailsView1.DataKey.Value.ToString()));
        if (productCount != 0)
        {
            lblProErr.Text = "Error：该分类下有商品，要删除该分类请先删除商品！";
            e.Cancel = true;
        }
    }


    protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        Response.Redirect("AssetCategory.aspx");
    }

    protected void DetailsView1_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
    {
        Response.Redirect("AssetCategory.aspx");
    }

    protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {
        Response.Redirect("AssetCategory.aspx");
    }

    protected void return_Click(object sender, EventArgs e)
    {
        Response.Redirect("MyWork.aspx");
    }
}